<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增托盘条码信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-traycode-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">条码头：</label>
                <div class="col-sm-8">
                    <select  id="tHead" name="tHead"  class="form-control" required onchange="addHead()">
                        <option value="">请选择</option>
                        <option th:each="item:${traycodeHeadList}"
                                th:value="${item.tHead}" th:text="${item.tHead}">
                        </option>
                    </select>
                </div>
            </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">托盘条码号：</label>
                        <div class="col-sm-8">
                            <input id="beginCode" name="beginCode" placeholder="请输入托盘条码号" autocomplete="off" class="form-control" type="text" maxlength="20"
                                   required readonly>
                        </div>



            </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">打印数量：</label>
                        <div class="col-sm-8">
                            <input id="beginCount" name="beginCount" placeholder="请输入打印数量" autocomplete="off" class="form-control" type="text" maxlength="20"
                                   required>
                        </div>



            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required" >是否可用：</label>
                <div class="col-sm-8">
                    <select name="isUsed" class="form-control" th:with="type=${@dict.getType('useable')}" required>
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "bas/traycode"
        $("#form-traycode-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-traycode-add').serialize());
            }
        }

        function addHead() {
            console.log($('#tHead').val());
            var text=$('#tHead').val();
            // var text1=text.replace(/[^a-zA-Z]/g,'');
            // var text2=text1.toUpperCase();
            // $("#tHead").val(text2);
            $.ajax({
                "url": "/bas/traycode/selectCount?tHead=" + text,
                "type": "GET",
                "dataType": "json",
                "success": function (result) {
                    console.log(result);
                    // var begin = result.success + 1;
                    $("#beginCode").val( result+1);
                }
            });
        }
    </script>
</body>
</html>